package org.budo.mongo.wrapper;

import java.util.List;
import java.util.Set;

import org.budo.mongo.filter.MongoFilter;
import org.budo.mongo.filter.MongoFilterChain;
import org.budo.mongo.filter.MongoFilterChainImpl;

import com.mongodb.CommandResult;
import com.mongodb.DB;
import com.mongodb.DBCollection;
import com.mongodb.DBEncoder;
import com.mongodb.DBObject;
import com.mongodb.Mongo;
import com.mongodb.ReadConcern;
import com.mongodb.ReadPreference;
import com.mongodb.WriteConcern;
import com.mongodb.WriteResult;
import com.mongodb.client.model.DBCreateViewOptions;

public class DBWrapper extends DB {
    private DB db;

    private MongoFilterChain filterChain;

    public DBWrapper(List<MongoFilter> filters, DB db, Mongo mongo, String name) {
        super(mongo, name);
        this.filterChain = new MongoFilterChainImpl(filters);
        this.db = db;
    }

    @Override
    public void addOption(int $0) {
        filterChain.db_addOption(this.db, $0);
    }

    @Override
    public WriteResult addUser(String $0, char[] $1) {
        return filterChain.db_addUser(this.db, $0, $1);
    }

    @Override
    public WriteResult addUser(String $0, char[] $1, boolean $2) {
        return filterChain.db_addUser(this.db, $0, $1, $2);
    }

    @Override
    public boolean collectionExists(String $0) {
        return filterChain.db_collectionExists(this.db, $0);
    }

    @Override
    public CommandResult command(DBObject $0) {
        return filterChain.db_command(this.db, $0);
    }

    @Override
    public CommandResult command(DBObject $0, DBEncoder $1) {
        return filterChain.db_command(this.db, $0, $1);
    }

    @Override
    public CommandResult command(DBObject $0, ReadPreference $1) {
        return filterChain.db_command(this.db, $0, $1);
    }

    @Override
    public CommandResult command(DBObject $0, ReadPreference $1, DBEncoder $2) {
        return filterChain.db_command(this.db, $0, $1, $2);
    }

    @Override
    public CommandResult command(String $0) {
        return filterChain.db_command(this.db, $0);
    }

    @Override
    public CommandResult command(String $0, ReadPreference $1) {
        return filterChain.db_command(this.db, $0, $1);
    }

    @Override
    public DBCollection createCollection(String $0, DBObject $1) {
        return filterChain.db_createCollection(this.db, $0, $1);
    }

    @Override
    public DBCollection createView(String $0, String $1, List $2) {
        return filterChain.db_createView(this.db, $0, $1, $2);
    }

    @Override
    public DBCollection createView(String $0, String $1, List $2, DBCreateViewOptions $3) {
        return filterChain.db_createView(this.db, $0, $1, $2, $3);
    }

    @Override
    public CommandResult doEval(String $0, Object... $1) {
        return filterChain.db_doEval(this.db, $0, $1);
    }

    @Override
    public void dropDatabase() {
        filterChain.db_dropDatabase(this.db);
    }

    @Override
    public Object eval(String $0, Object... $1) {
        return filterChain.db_eval(this.db, $0, $1);
    }

    @Override
    public DBCollection getCollection(String $0) {
        return filterChain.db_getCollection(this.db, $0);
    }

    @Override
    public DBCollection getCollectionFromString(String $0) {
        return filterChain.db_getCollectionFromString(this.db, $0);
    }

    @Override
    public Set getCollectionNames() {
        return filterChain.db_getCollectionNames(this.db);
    }

    @Override
    public Mongo getMongo() {
        return filterChain.db_getMongo(this.db);
    }

    @Override
    public String getName() {
        return filterChain.db_getName(this.db);
    }

    @Override
    public int getOptions() {
        return filterChain.db_getOptions(this.db);
    }

    @Override
    public ReadConcern getReadConcern() {
        return filterChain.db_getReadConcern(this.db);
    }

    @Override
    public ReadPreference getReadPreference() {
        return filterChain.db_getReadPreference(this.db);
    }

    @Override
    public DB getSisterDB(String $0) {
        return filterChain.db_getSisterDB(this.db, $0);
    }

    @Override
    public CommandResult getStats() {
        return filterChain.db_getStats(this.db);
    }

    @Override
    public WriteConcern getWriteConcern() {
        return filterChain.db_getWriteConcern(this.db);
    }

    @Override
    public WriteResult removeUser(String $0) {
        return filterChain.db_removeUser(this.db, $0);
    }

    @Override
    public void resetOptions() {
        filterChain.db_resetOptions(this.db);
    }

    @Override
    public void setOptions(int $0) {
        filterChain.db_setOptions(this.db, $0);
    }

    @Override
    public void setReadConcern(ReadConcern $0) {
        filterChain.db_setReadConcern(this.db, $0);
    }

    @Override
    public void setReadPreference(ReadPreference $0) {
        filterChain.db_setReadPreference(this.db, $0);
    }

    @Override
    public void setWriteConcern(WriteConcern $0) {
        filterChain.db_setWriteConcern(this.db, $0);
    }

    @Override
    public void slaveOk() {
        filterChain.db_slaveOk(this.db);
    }

    @Override
    public String toString() {
        return filterChain.db_toString(this.db);
    }

}